<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2022/5/7
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-body">

    <form class="layui-form">
        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>书名
            </label>
            <div class="layui-input-inline">
                <input type="hidden" id="bookId" name="bookId">
                <input type="text" id="bookName" name="bookName" required=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>作者
            </label>
            <div class="layui-input-inline">
                <input type="text" id="bookWriter" name="bookWriter" required=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>类型
            </label>
            <div class="layui-input-inline">
                <input type="text" id="bookType" name="bookType" required=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>


        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>书本剩余数量
            </label>
            <div class="layui-input-inline">
                <input type="text" id="bookNums" name="bookNums" required=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label">
            </label>
            <button  class="layui-btn" type="button" onclick="updateUser()">
                修改
            </button>
        </div>
    </form>
</div>
<script>
    var bookId = localStorage.getItem("bookId");
    function updateUser() {
        var bookName = $("#bookName").val();
        var bookWriter = $("#bookWriter").val();
        var bookType = $("#bookType").val();
        var bookNums = $("#bookNums").val();

        $.ajax({
            url:"manageBook/manage-updateBook",
            type:"post",
            dataType:"json",
            data:{
                bookId:bookId,bookName:bookName,
                bookWriter:bookWriter,bookType:bookType,
                bookNums:bookNums
            },
            success:function (rs) {
                if (rs.code == 200){
                    layer.alert(rs.msg,{icon:6},function () {
                        x_admin_close();
                        parent.window.loadData();
                    })
                }
            }
        })
    }

    //取出本地变量存储的值，并数据回显
    function getLocalStorage(){
        $("#bookName").val(localStorage.getItem("bookName"));
        $("#bookWriter").val(localStorage.getItem("bookWriter"));
        $("#bookType").val(localStorage.getItem("bookType"));
        $("#bookNums").val(localStorage.getItem("bookNums"));
    }
    //一打开页面就立马显示数据
    $(function () {
        getLocalStorage();
    })

    
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>
